import LinvoDB from './api'
var modelName = "user";
var schema = { }; // Non-strict always, can be left empty
var options = { };

//创建数据表
const userDB = new LinvoDB(modelName, schema,options)

export default class PayMethodDao {
    //数据库操作工具方法
    static insertData(data) {
        return new Promise((resolve, reject) => {
            userDB.insert(data,function (err,newInvoice) {
                // console.log(666,newInvoice)
                resolve(err)
            })
        })
    }

    static removeData(data) {
        return new Promise((resolve, reject) => {
            userDB.remove(data,{ multi: true },function (err,newInvoice) {
                // console.log(666,newInvoice)
                resolve(err)
            })
        })
    }


    static updateData(query,data) {
        return new Promise((resolve, reject) => {
            userDB.update(query,{ $set: data},{},function (err,numReplaced) {
                // console.log(666,newInvoice)
                resolve(err)
            })
        })
    }

    static findListNoPage(data) {
        return new Promise((resolve, reject) => {
            userDB.find(data).sort({"createAt":1})
                .exec(function (err, results) {
                    resolve(results);
                });
        })
    }
}
